home *** CD-ROM | disk | FTP | other *** search
/ Programmers Heaven 2 / Programmers Heaven 2.iso / files / graphics / library / wgt51_r2.zip / WGT5 / EXAMPLES / WGT15.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-03  |  2.6 KB  |  78 lines

  1. /*
  2. ==============================================================================
  3.               WordUp Graphics Toolkit Version 5.0                     
  4.                  Demonstration Program 15                         
  5.                                           
  6.  This program shows how to use virtual graphics pages and tells how           
  7.  they are used in animation.                                                  
  8.                                           
  9.  *** PROJECT ***                                                             
  10.  This program requires the file WGT5_WC.LIB to be linked.                    
  11.                                           
  12.  *** DATA FILES ***                                                          
  13.  NONE                                                                        
  14.                                WATCOM C++ VERSION 
  15. ==============================================================================
  16. */
  17.  
  18. #include <conio.h>
  19. #include <wgt5.h>
  20.  
  21.  
  22. void main(void)
  23. {
  24.   short x,y;
  25.   short oldmode;
  26.   block screen1;
  27.   
  28.   printf ("WGT Example #15\n\n");
  29.   printf ("This program demonstrates virtual screen buffers.\n");
  30.   printf ("Press a key after the tone is heard, then again to end the demo.\n");
  31.   printf ("\n\nPress any key to continue.\n");
  32.   getch ();
  33.  
  34.   if ( !vgadetected () )
  35.   {
  36.     printf("Error - VGA card required for any WGT program.\n");
  37.     exit (0);
  38.   }
  39.   oldmode = wgetmode ();
  40.   vga256 ();
  41.  
  42.   screen1 = wnewblock (0, 0, 319, 199);
  43.       /* virtual screens are created by making a block of any size.
  44.      These screens can be used like any other block, however they may
  45.      also be drawn on top of. You can tell which screen to draw to by 
  46.      calling wsetscreen(name of block) and wnormscreen() to restore
  47.      drawing to the default screen.
  48.      Note: wsetscreen(NULL); performs the same action as wnormscreen();
  49.       */
  50.  
  51.   wtextcolor (15);
  52.   wouttextxy (0, 0, NULL, "Press a key at the tone");
  53.   wsetscreen (screen1);          /* sets to screen1 */
  54.   for (y = 0; y < 200; y++)
  55.   {
  56.     wsetcolor (y);
  57.     wline (0, 0, 319, y);           /* draw something on another screen */
  58.     wline (319, 199, 0, y);
  59.   }
  60.  
  61.   sound (500);           /* This is to let you know when it is finished */
  62.   delay (100);
  63.   nosound ();
  64.   getch ();              /* there is nothing on the screen yet */
  65.  
  66.   /* now use putblock to show what happened on the other screen */
  67.  
  68.   wnormscreen ();                /* make the putblock go onto the default screen */
  69.   wputblock (0, 0, screen1, 0);
  70.  
  71.   getch ();              /* now everything is shown! */
  72.  
  73.   wfreeblock (screen1);
  74.   /* remember to free that memory (64004 bytes for a screen) */
  75.  
  76.   wsetmode (oldmode);
  77. }
  78.